import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import frontIndex from '@/components/front/frontIndex/index'
// 解决两次访问相同路由地址报错
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: index
    },
    {
      path: '/front/index',
      name: 'frontIndex',
      component: frontIndex,
      children:[
        {
          path: '/home',
          name: 'Home',
          component: () => import('@/components/front/home')
        },
        {
          path: '/order',
          name: 'Order',
          // meta: { authorization: true },
          component: () => import('@/components/front/order')
        },
        {
          path: '/user',
          name: 'User',
          meta: { authorization: true },
          component: () => import('@/components/front/user')
        },
        {
          path: '/news',
          name: 'News',
          meta: { authorization: true },
          component: () => import('@/components/front/user')
        }
      ]
    }
  ]
})
